package com.nyj.sqlSession;

import com.nyj.config.XMLConfigBuilder;
import com.nyj.pojo.Configuration;

import java.io.InputStream;

/**
 * @author niuyj
 * @date 2020/4/29 23:52
 * @description
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream inputStream){
        //1.利用dom4j解析配置文件，解析出的内容封装在Configuration类中
            //新创建类用来解析xml文件
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);

        //创建SqlSessionFactory对象
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);

        return  defaultSqlSessionFactory;

    }
}
